import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-07-18
 * Time: 10:00
 */
public class Test {
    public static void main(String[] args) {

    }
    public static void main8(String[] args) {
        String s1 = "world";
        String s2 = "WORLD";

        //转为大写
        System.out.println(s1.toUpperCase());

        //转为小写
        System.out.println(s2.toLowerCase());
    }
    public static void main7(String[] args) {
        String s1 = String.valueOf(2456);
        String s2 = String.valueOf(24.56);
        String s3 = String.valueOf(true);

        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
    }
    public static void main6(String[] args) {
        String ss = "abcdefga";
        System.out.println(ss.lastIndexOf('a'));
    }
    public static void main5(String[] args) {
        String ss = "abcdefghi";
        System.out.println(ss.charAt(2));
    }
    public static void main4(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("abcd");
        String s3 = new String("abcdfg");
        String s4 = new String("abc");

        System.out.println(s2.compareTo(s1));
        System.out.println(s2.compareTo(s3));
        System.out.println(s2.compareTo(s4));
    }
    public static void main3(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = new String("Hello");

        System.out.println(s1.equals(s2));//true
        System.out.println(s1.equals(s3));//false

    }

    public static void main2(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("world");
        String s3 = s1;

        System.out.println(s1 == s2);//false
        System.out.println(s1 == s3);//true
        System.out.println(s2 == s3);//false
    }
    public static void main1(String[] args) {
        //1.使用常量串构造
        String s1 = "helloworld";

        //2.直接newString对象
        String s2 = new String("helloworld");

        //3.使用字符串数组构造
        char[] arr = {'h','e','l','l','o'};
        String s3 = arr.toString();
    }
}
